<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"    uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">生成修改派车单</li>
    </ol>
    
    <div class="ms-content-layout">
    
      <div class="block-heading">
         <h5>派车单信息</h5>
      </div>
      
      <form id="validate-form" class="form-horizontal ms-form form-personal-info">
        

        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">派车单号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${dispatchOrder.code}</p>
          </div>
          <label class="col-xs-2 control-label">调度指令组号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.shipmentGroupId} </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">起始地：</label>
          <div class="col-xs-3 ">
            <p class ="form-control-static">
              ${empty dispatchOrder.startFacilityId ? '' : ( persist.loadPlace(dispatchOrder.startFacilityId).code ).concat( '-' ).concat( persist.loadPlace(dispatchOrder.startFacilityId).name )}
            </p>
          </div>
          <label class="col-xs-2 control-label">目的地：</label>
           <div class="col-xs-3 ">
             <p class ="form-control-static">
               ${empty dispatchOrder.destinationFacilityId ? '' : (persist.loadPlace(dispatchOrder.destinationFacilityId).code).concat('-').concat(persist.loadPlace(dispatchOrder.destinationFacilityId).name)}
             </p>
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">派车单日期：</label>
          <div class="col-xs-3 ">
            <p class ="form-control-static"><fmt:formatDate value="${dispatchOrder.dispatchDate}" pattern="yyyy-MM-dd"/> </p>
          </div>
          <label class="col-xs-2 control-label">驳运车号：</label>
           <div class="col-xs-3 ">
             <p class ="form-control-static">
               ${empty dispatchOrder.vehicleId ? '' : (persist.vehicle(dispatchOrder.vehicleId).code).concat('-').concat(persist.vehicle(dispatchOrder.vehicleId).name)}
             </p>
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">默认行驶公里数：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value='${dispatchOrder.facilityDistanceDefault}' minFractionDigits='2'/></p>
          </div>
          <label class="col-xs-2 control-label">行驶公里数调整类型：</label>
          <div class="col-xs-3"> 
            <c:forEach items="${enums['DistanceAdjustType']}" var="type">
	            <c:if test="${dispatchOrder.distanceAdjustType == type.description}">
	            	<p class="form-control-static"> ${type.description}</p>
	            </c:if>
            </c:forEach>  
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">行驶公里数调整：</label>
          <div class="col-xs-3">
            <p type="text" name="adjustmentDistance" class="form-control-static" placeholder="请填写行驶公里数调整数" 
                tabindex="2" autocomplete="off"><fmt:formatNumber value='${dispatchOrder.facilityDistance - dispatchOrder.facilityDistanceDefault}' pattern = '#00.00' minFractionDigits='2'/></p>
          </div>
          
          <label class="col-xs-2 control-label">行驶公里数调整理由补充：</label>
          <div class="col-xs-3">
            <textarea readOnly name="distanceAdjustRemark" rows="4" cols="60" tabindex="3" >${dispatchOrder.distanceAdjustRemark}</textarea>
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾驶员：</label>
          <div class="col-xs-3 modal-search-warp">
            <p type="text" data-validate="required" name="mainDriver"  autocomplete="off" tabindex="4" data-org="organizationId"
                              class="form-control-static eId-search modal-search" data-value-name="mainDriverId" 
                              placeholder="请填写主驾驶员"  data-modal-search="#modal-search-eId">${empty dispatchOrder.mainDriverId ? '' : (persist.employee(dispatchOrder.mainDriverId).code).concat(' - ').concat(persist.employee(dispatchOrder.mainDriverId).name)}</p>
          </div>
          
          <label class="col-xs-2 control-label">第一副驾驶员：</label>
          <div class="col-xs-3 modal-search-warp">
            <p type="text" name="firstViceDriver" autocomplete="off" tabindex="5" data-org="organizationId"  
                               class=" fId-search modal-search" data-value-name="firstViceDriverId"
                                placeholder="请填写第一副驾驶员"  data-modal-search="#modal-search-fId">${empty dispatchOrder.firstViceDriverId ? '' : (persist.employee(dispatchOrder.firstViceDriverId).code).concat(' - ').concat(persist.employee(dispatchOrder.firstViceDriverId).name)}</p>
          </div>
        </div>
        
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">路桥费：</label>
          <div class="col-xs-3">
            <p type="text" name="roadFee" class=""   tabindex="6" autocomplete="off" ><fmt:formatNumber value='${transportCost.roadFee}' minFractionDigits='2' pattern = '#00.000'/></p>
          </div>
          <label class="col-xs-2 control-label">修理费：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.repairFee}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">轮胎费：</label>
          <div class="col-xs-8">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.tyreFee}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾重载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.mainDriverFullSalary}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">主驾空载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> <fmt:formatNumber value="${transportCost.mainDriverEmptySalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾工资：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.mainDriverSalary}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">第一副驾重载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.firstViceDriverFullSalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">第一副驾空载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.firstViceDriverEmptySalary}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">第一副驾工资：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.firstViceDriverSalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">重载油耗：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.fullOilUsagePerKm}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">空载油耗：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.emptyOilUsagePerKm}" minFractionDigits="2"/></p>
          </div>
        </div>
        
         <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">满载数量：</label>
          <div class="col-xs-3">
            <p type="text" name="fullLoadNumber" class="form-control-static" data-validate="number|min,1" placeholder=""  tabindex="7" autocomplete="off">${dispatchOrder.fullLoadNumber}</p>
          </div>
          
          <label class="col-xs-2 control-label">加油类型：</label>
          <div class="col-xs-3">
          
           <c:forEach items="${enums['OilType']}" var="oilType">
             <p class="form-control-static">${transportCost.oilTypeId == oilType.id ? oilType.description : ''}</p>
           </c:forEach>
          
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">加油量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.oilUsage}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">内部加油量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.internalOilUsage}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">内部油价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.internalOilPrice}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">外部油价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.externalOilPrice}" minFractionDigits="2"/></p>
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">油费：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${transportCost.totalOilFeeReimbursed}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">是否回单确认：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.accomplishConfirm ? "是" : "否"}</p>
          </div>
          <label class="col-xs-2 control-label">回单数量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${dispatchOrder.accomplishConfirmNumber}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">是否已打印过报销单：</label>
          <div class="col-xs-3">
            <p class ="form-control-static" style="color:${dispatchOrder.expensePrint ? 'red' : 'green'};">${dispatchOrder.expensePrint ? "已打印" : "未打印"}</p>
          </div>
          <label class="col-xs-2 control-label">备注：</label>
          <div class="col-xs-3">
            <textarea readOnly name="remarks" rows="4" cols="60" tabindex="9">${dispatchOrder.remarks}</textarea>
          </div>
        </div>
        
        <div class="block-heading">
          <h5>其他费用列表</h5>
        </div>
        
        <table class="table table-hover ms-table shipment-car-table">
          <thead>
            <tr>
              <th>其它费用名称</th>
              <th>金额</th>
              <th>安吉物流设置金额</th>
            </tr>
          </thead>
          
          <tbody>
            
            <c:forEach items="${otherFeeMap.keySet()}" var="otherFeeTypeId">
              <tr>
                <td>${otherFeeMap[otherFeeTypeId].feeName}</td>
                <td>
	                <p type="text" name="otherFees" >${otherFeeMap[otherFeeTypeId].otherFee == null ? '0.00' : otherFeeMap[otherFeeTypeId].otherFee}</p>
                  <span class="glyphicon glyphicon-ok color-red" style="display: none;"></span>
	                <p type="hidden" name="otherFeeTypeIds" value="${otherFeeTypeId}"/>
                </td>
                <td>${otherFeeMap[otherFeeTypeId].anjiFee}</td>
              </tr>
            </c:forEach>
            
            <tr>
              <td colspan="3">
                <div>其他费用审核人：<p type="text" name="otherFeeAuditor">${transportCost.otherFeeAuditor}</p></div>
              </td>
            </tr>
            
          </tbody>
          
        </table>

        <div class="block-heading">
          <h5>商品车明细列表</h5>
          <h5 style="margin-left: 70%;">调度数量：${dispatchOrder.actualLoadNumber}</h5>
        </div>
        
        <c:forEach items="${shipmentOrders}" var="order">
        
          <div class="form-horizontal ms-form form-personal-info">
        
            <div class="form-group ms-form-group">
              <div class="col-xs-3"> 
                <p class ="form-control-static">订单号：${order.code}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">客户：${order.client}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">订单起始地：${order.startFacility}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">订单目的地：${order.endFacility}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">单价：<fmt:formatNumber value="${order.contractRate}" minFractionDigits="2"/></p>
              </div>
            </div>
            
          </div>
        
          <table class="table table-hover ms-table">
            <thead class="blue-header">
              <tr>
                <th>VIN码</th>
                <th>数量</th>
                <th>车型</th>
                <th>颜色</th>
                <th>运输方式</th>
                <th>装车道号</th>
                <th>制造商</th>
                <th>起始地</th>
                <th>目的地</th>
                <th>目的地地址</th>
                <th>目的地联系电话</th>
                <th>预计起运时间</th>
                <th>预计装运时间</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${order.shipmentOrderItems}" var="item">
                <tr>
                  <td>${item.vinCode}</td>
                  <td>${item.quantity}</td>
                  <td>${item.carType}</td>
                  <td>${item.carColor}</td>
                  <td>${item.transType}</td>
                  <td>${item.driveWay}</td>
                  <td>${item.manufactor}</td>
                  <td>${item.startFacility}</td>
                  <td>${item.endFacility}</td>
                  <td>${item.destinationAddress}</td>
                  <td>${item.destinationTelecomNumber}</td>
                  <td>${item.deptDate}</td>
                  <td>${item.loadDate}</td>
                </tr>
              </c:forEach>
            </tbody>
          </table>

        </c:forEach>

        <div class="form-group ms-form-group">
          <div class="col-xs-6 col-xs-offset-3 ms-operation-group top-margin-20 text-center">
            <div class="col-xs-5">
              <a href="${ctx.host}/dispatch-orders/${dispatchOrder.id}/prepare?maintain=direct" class="btn btn-block btn-default">修改</a>
            </div>
            <div class="col-xs-5">
              <a href="${ctx.host}/shipment-lines?${sessionScope.generateQueryString}" class="btn btn-block btn-primary">返回</a>
            </div>
          </div>
        </div>

      </form>
    
    </div> 
  </div>       
  
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/business/shipment/shipment-generate-update-view.js" />
  <script type="text/javascript">
	  require(['page/business/shipment/shipment-generate-update-view'], function(page) {
	    page.init({
	      actualLoadNumber:'${dispatchOrder.actualLoadNumber}'
	    })
	  })
  </script>

</body>
</html>